import Vue from 'vue'
import VeeValidate, { Validator } from 'vee-validate'
import cn from 'vee-validate/dist/locale/zh_CN'
Validator.localize('cn', cn)
const isMobile = {
  getMessage (field, args) {
    return field + '必须是11位手机号码'
  },
  validate: (value, args) => {
    return value.length === 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(value)
  }
}
const isChinese = {
  getMessage (field, args) {
    return field + '必须是中文'
  },
  validate: (value, args) => {
    return value.length && /^[\u4e00-\u9fa5]+$/.test(value)
  }
}
Validator.extend('mobile', isMobile)
Validator.extend('chinese', isChinese)
Vue.use(VeeValidate, { events: 'change' })
Validator.localize('cn', cn)
